// Copyright (c) 2025, hzmes and contributors
// For license information, please see license.txt

frappe.query_reports["Project Cost Analyse2"] = {
	filters: [
		{
			fieldname: "year",
			fieldtype: "Int",
			label: "年",
			default: 2025
		},
		{
			fieldname: "fperiod",
			fieldtype: "Int",
			label: "账期",
			default: 1,
		},
		{
			fieldname: "expense_claim_type",
			fieldtype: "Link",
			label: "费用项目",
			options: "Expense Claim Type",
		},
		{
			fieldname: "test",
			fieldtype: "Link",
			label: "Test",
			options: "Expense Allocation Doc",
			default: "",
			get_query: () => {
				let year = frappe.query_report.get_filter_value("year");
				let fperiod = frappe.query_report.get_filter_value("fperiod");
				let expense_claim_type = frappe.query_report.get_filter_value("expense_claim_type");
				console.log(year);
				console.log(fperiod);
				console.log(expense_claim_type);
				if (expense_claim_type != "") {
					return {
						 query: "hzplm.hz_plm.doctype.expense_allocation_doc.expense_allocation_doc.expense_allocation_doc_query",
						filters: {
							year: year,
							fperiod: fperiod,
							expense_claim_type: expense_claim_type,
						},
					};
				}
			},
		},
	]
};

